package com.platform.common.exception;


import com.platform.common.enums.HttpStatus;

/**
 * @author guoyunfei on 2021/11/26 13:10
 * @className ApiException
 * @description TODO
 * @Version 1.0
 */

public class ApiException extends RuntimeException{

    /**
     *
     */
    private static final long serialVersionUID = -4137688758944857209L;

    /**
     * http状态码
     */
    private Integer httpStatusCode;


    /**
     * @param httpStatus http状态码
     */
    public ApiException(HttpStatus httpStatus) {
        super(httpStatus.getMsg());
        this.httpStatusCode = httpStatus.value();
    }

    /**
     * @param httpStatus http状态码
     */
    public ApiException(HttpStatus httpStatus, String msg) {
        super(msg);
        this.httpStatusCode = httpStatus.value();
    }


    public ApiException(String msg) {
        super(msg);
        this.httpStatusCode = org.springframework.http.HttpStatus.BAD_REQUEST.value();
    }


    public Integer getHttpStatusCode() {
        return httpStatusCode;
    }


}
